package com.biboheart.adapter.express.support;

import com.biboheart.adapter.express.actuator.GenericActuator;
import com.biboheart.adapter.support.utils.ObjectTypeUtils;
import com.biboheart.adapter.support.utils.TimeUtils;

final class TimestampActuator implements GenericActuator {
    @Override
    public Object execute(Object source, Object... args) {
        if (null == source) {
            return System.currentTimeMillis();
        }
        Object arg1 = args.length > 0 ? args[0] : null;
        String format = null;
        if (arg1 instanceof String) {
            format = ObjectTypeUtils.convertType(arg1, String.class);
        }
        return TimeUtils.getDateMillis(ObjectTypeUtils.convertType(source, String.class), format);
    }
}
